package com.zhuss.order.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.order.order.CreateOrderBo;
import com.zhuss.bean.bo.order.order.DeleteOrderBo;
import com.zhuss.bean.bo.order.order.UpdateOrderBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.OceanException;

/**
 * @description: 订单操作的Service
 * @author: zhushanshuo
 * @create: Wed Mar 24 22:32:50 CST 2021
 **/
@Component("orderOperateService")
public class OrderOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("orderCreate")
	private Processor<Object, CreateOrderBo> orderCreate;
	
	@Autowired
	@Qualifier("orderUpdate")
	private Processor<Object, UpdateOrderBo> orderUpdate;
	
	@Autowired
	@Qualifier("orderDelete")
	private Processor<Object, DeleteOrderBo> orderDelete;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws OceanException {
		
		CreateOrderBo bo = (CreateOrderBo) param;
		
		orderCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws OceanException {
    	
		UpdateOrderBo bo = (UpdateOrderBo) param;
		
		orderUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws OceanException {
		
		DeleteOrderBo bo = (DeleteOrderBo) param;
		
		orderDelete.process(bo);
		
		return null;
	}
	
}

